﻿<template>
	<div class="card-fill layout-padding">
		<el-card shadow="hover" class="layout-padding-auto">
			<el-tabs v-model="activeTab">
				<el-tab-pane label="基本信息" name="main">
					<el-form ref="formRefFrameworkUser" :model="stateFrameworkUser.vmModel" label-width="120px">
						<el-row>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item
									ref="Entity_ITCode_FormItem"
									prop="Entity.ITCode"
									:label="$t('message.autotrans._Model_FrameworkUser_ITCode')"
									:rules="[
										{
											required: true,
											message: $t('message._system.common.vm.input', { input: $t('message.autotrans._Model_FrameworkUser_ITCode') }),
											trigger: 'blur',
										},
									]"
								>
									<el-input v-model="stateFrameworkUser.vmModel.Entity.ITCode" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item
									ref="Entity_Name_FormItem"
									prop="Entity.Name"
									:label="$t('message.autotrans._Model_FrameworkUser_Name')"
									:rules="[
										{
											required: true,
											message: $t('message._system.common.vm.input', { input: $t('message.autotrans._Model_FrameworkUser_Name') }),
											trigger: 'blur',
										},
									]"
								>
									<el-input v-model="stateFrameworkUser.vmModel.Entity.Name" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item
									ref="Entity_IsValid_FormItem"
									prop="Entity.IsValid"
									:label="$t('message.autotrans._Model_FrameworkUser_IsValid')"
									:rules="[
										{
											required: true,
											message: $t('message._system.common.vm.input', { input: $t('message.autotrans._Model_FrameworkUser_IsValid') }),
											trigger: 'blur',
										},
									]"
								>
									<el-switch v-model="stateFrameworkUser.vmModel.Entity.IsValid" disabled></el-switch>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item ref="Entity_PhotoId_FormItem" prop="Entity.PhotoId" :label="$t('message.autotrans._Model_FrameworkUser_Photo')">
									<wtm-upload-image v-model="stateFrameworkUser.vmModel.Entity.PhotoId" clearable disabled style="width: 300px" thumb-width="128" />
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item ref="Entity_CellPhone_FormItem" prop="Entity.CellPhone" :label="$t('message.autotrans._Model_FrameworkUser_CellPhone')">
									<el-input v-model="stateFrameworkUser.vmModel.Entity.CellPhone" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item
									ref="Entity_CreateTime_FormItem"
									prop="Entity.CreateTime"
									:label="$t('message.autotrans._Model_FrameworkUser_CreateTime')"
								>
									<el-input v-model="stateFrameworkUser.vmModel.Entity.CreateTime" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item
									ref="Entity_UpdateTime_FormItem"
									prop="Entity.UpdateTime"
									:label="$t('message.autotrans._Model_FrameworkUser_UpdateTime')"
								>
									<el-input v-model="stateFrameworkUser.vmModel.Entity.UpdateTime" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_FrameworkUser_CreateBy')">
									<el-input v-model="stateFrameworkUser.vmModel.Entity.CreateBy" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_FrameworkUser_UpdateBy')">
									<el-input v-model="stateFrameworkUser.vmModel.Entity.UpdateBy" disabled clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item ref="Entity_GroupId_FormItem" prop="SelectedFrameworkUserGroupsIDs" :label="$t('message.autotrans._AdminGroup')">
									<el-cascader
										:options="stateFrameworkUser.AllFrameworkUserGroups"
										:props="{ multiple: true, checkStrictly: true, emitPath: false, label: 'Text', value: 'Value', children: 'Children' }"
										filterable
										class="w100"
										v-model="stateFrameworkUser.vmModel.SelectedFrameworkUserGroupsIDs"
										disabled
									></el-cascader>
								</el-form-item>
							</el-col>
							<el-col :xs="24" :lg="12" class="mb20">
								<el-form-item ref="Entity_RoleId_FormItem" prop="SelectedFrameworkUserRolesIDs" :label="$t('message.autotrans._AdminRole')">
									<el-cascader
										:options="stateFrameworkUser.AllFrameworkUserRoles"
										:props="{ multiple: true, checkStrictly: true, emitPath: false, label: 'Text', value: 'Value', children: 'Children' }"
										filterable
										class="w100"
										v-model="stateFrameworkUser.vmModel.SelectedFrameworkUserRolesIDs"
										disabled
									></el-cascader>
								</el-form-item>
							</el-col>
						</el-row>

						<div style="text-align: right">
							<WtmButton @click="onCloseFrameworkUser" type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top: 15px" />
						</div>
					</el-form>
				</el-tab-pane>
				<el-tab-pane label="岗位信息" name="position">
					<SysUserJobPosition
						:key="stateFrameworkUser.vmModel.Entity.ID || ''"
						:search-bar="false"
						:toolbar="true"
						:is-disabled="true"
						:UserId="stateFrameworkUser.vmModel.Entity.ID"
					/>
				</el-tab-pane>
			</el-tabs>
		</el-card>
	</div>
</template>

<script setup lang="ts" name="message.autotrans._Page_AdminFrameworkUserDetails;false">
import { reactive, ref, getCurrentInstance, onMounted } from 'vue';
import { frameworkuserApi } from '/@/api/_admin/frameworkuser';
import other from '/@/utils/other';
import { useRouter } from 'vue-router';

import SysUserJobPosition from '/@/views/_admin/sysuserjobposition/index.vue';

// 定义变量内容
const activeTab = ref('main');
const ci = getCurrentInstance() as any;
const formRefFrameworkUser = ref();
const stateFrameworkUser = reactive({
	vmModel: {
		Entity: {
			ITCode: '',
			Name: '',
			IsValid: undefined,
			PhotoId: null,
			CreateTime: undefined,
			UpdateTime: undefined,
			CreateBy: '',
			UpdateBy: '',
			ID: null,
			CellPhone: null,
		},
		SelectedFrameworkUserRolesIDs: [],
		SelectedFrameworkUserGroupsIDs: [],
	},
	AllFrameworkUserRoles: [] as any[],
	AllFrameworkUserGroups: [] as any[],
});

// 取消
const onCloseFrameworkUser = () => {
	closeDialog();
};

// 页面加载时
onMounted(() => {
	if (ci.attrs['wtmdata']) {
		stateFrameworkUser.vmModel.Entity.ID = ci.attrs['wtmdata'].ID;
	} else if (useRouter().currentRoute.value.query.id) {
		stateFrameworkUser.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	frameworkuserApi()
		.get(stateFrameworkUser.vmModel.Entity.ID ?? '')
		.then((data: any) => other.setValue(stateFrameworkUser.vmModel, data));

	other.getSelectList('/api/_Admin/FrameworkUser/GetFrameworkGroups?istree=true', [], true).then((x) => {
		stateFrameworkUser.AllFrameworkUserGroups = x;
	});
	other.getSelectList('/api/_Admin/FrameworkUser/GetFrameworkRoles', [], false).then((x) => {
		stateFrameworkUser.AllFrameworkUserRoles = x;
	});
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh', 'closeDialog']);
// 关闭弹窗
const closeDialog = () => {
	emit('closeDialog');
};
// 暴露变量
defineExpose({});
</script>

<style scoped lang="scss"></style>
